package com.javakc.copyrightin.chapter.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.javakc.copyrightin.book.entity.Book;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;

/**
 * @author : http://www.chiner.pro
 * @date : 2021-11-5
 * @desc : 临时章节表 - 实体类
 */
@Data
@Entity
@Table(name="bms_chapter_temp")
@EntityListeners(AuditingEntityListener.class)
public class Chapter {
        /** 主键 */
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id")
        @ApiModelProperty(value = "章节主键")
        private Integer id ;

        /** 章节名 */
        @Column(name = "name")
        @ApiModelProperty(value = "章节名")
        private String name ;

        /** 章节序号 */
        @Column(name = "number")
        @ApiModelProperty(value = "章节序号")
        private Integer number ;

        /** 章节状态 */
        @Column(name = "status")
        @ApiModelProperty(value = "章节状态 1:已入库 0:未入库")
        private Integer status ;

        /** 更新时间 */
        @Column(name = "update_time")
        @ApiModelProperty(value = "更新时间")
        private Date updateTime ;

        /** 书籍外键 */


//        @Column(name = "book_id")
//        @ApiModelProperty(value = "书籍外键")
//        private Integer bookId ;

        /** 章节内容 */
        @Column(name = "content")
        @ApiModelProperty(value = "章节内容")
        private String content ;

        @Column(name = "bms_create",updatable = false)
        @ApiModelProperty(value = "创建时间", example = "2020-12-12 9:00:00")
        @CreatedDate
        @JsonFormat(pattern = "yyyy-MM-dd HH-mm-ss", timezone = "GMT+8")
        private Date bmsCreate ;

        @Column(name = "bms_modified",insertable = false)
        @ApiModelProperty(value = "更新时间", example = "2020-12-12 9:00:00")
        @LastModifiedDate
        @JsonFormat(pattern = "yyyy-MM-dd HH-mm-ss", timezone = "GMT+8")
        private Date bmsModified ;


        @ManyToOne
        @JoinColumn(name = "book_id")
        private Book book;


}
